package com.xbongbong.sys.model.impl;

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.sys.domain.dao.TargetLogDao;
import com.xbongbong.sys.domain.entity.TargetLogEntity;
import com.xbongbong.sys.model.TargetLogModel;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * Description:
 *
 * @author 李杰
 * @version v1.0
 * @date 2019/2/19 15:53
 * @since v1.0
 */
@Component
public class TargetLogModelImpl implements TargetLogModel {

    @Resource
    private TargetLogDao targetLogDao;

    @Override
    public Integer insert(TargetLogEntity entity) {
        Integer now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);

        return targetLogDao.insert(entity);
    }

    @Override
    public Integer update(TargetLogEntity entity) {
        entity.setUpdateTime(DateUtil.getInt());

        return targetLogDao.update(entity);
    }

    @Override
    public Integer save(TargetLogEntity entity) {
        if (entity.getId() == null || Objects.equals(0, entity.getId())) {
            return targetLogDao.insert(entity);
        }
        return targetLogDao.update(entity);
    }

    @Override
    public Integer deleteByKey(Integer key, String corpid) {
        return targetLogDao.deleteByKey(key, corpid);
    }

    @Override
    public TargetLogEntity getByKey(Integer key, String corpid) {
        return targetLogDao.getByKey(key, corpid);
    }

    @Override
    public List<TargetLogEntity> findEntitys(Map<String, Object> param) {
        return targetLogDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return targetLogDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }
}

 